<%@ page import="com.ws.q1.conifg.Res" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <title>修改旅游线路</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .form-container {
            max-width: 800px;
            margin: 30px auto;
            padding: 20px;
            background-color: #f8f9fa;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        .required-label::after {
            content: "*";
            color: red;
            margin-left: 3px;
        }
        .preview-image {
            max-width: 200px;
            margin-top: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            padding: 5px;
        }
    </style>
</head>
<body>
<div class="container">
    <div class="form-container">
        <h2 class="mb-4 text-center">修改旅游线路</h2>
        <form action="${pageContext.request.contextPath}/xianlu/update" method="post" enctype="multipart/form-data">
            <input type="hidden" name="id" value="${huixian.id}">

            <%-- 基础信息 --%>
            <div class="row mb-3">
                <div class="col-md-6">
                    <label class="form-label required-label">线路名称</label>
                    <input type="text" class="form-control" name="name"
                           value="${huixian.name}" required>
                </div>
                <div class="col-md-6">
                    <label class="form-label required-label">价格(元)</label>
                    <input type="number" class="form-control" name="price"
                           value="${huixian.price}" min="1" required>
                </div>
            </div>

            <%-- 地点信息 --%>
            <div class="row mb-3">
                <div class="col-md-6">
                    <label class="form-label required-label">出发地</label>
                    <input type="text" class="form-control" name="chufadi"
                           value="${huixian.chufadi}" required>
                </div>
                <div class="col-md-6">
                    <label class="form-label required-label">目的地</label>
                    <input type="text" class="form-control" name="mudidi"
                           value="${huixian.mudidi}" required>
                </div>
            </div>

            <%-- 下拉选择 --%>
            <div class="row mb-3">
                <div class="col-md-6">
                    <label class="form-label required-label">所属栏目</label>
                    <select class="form-select" name="lanmu_name" required>
                        <option value="">-- 请选择 --</option>
                        <c:forEach items="${list1}" var="lanmu">
                            <option value="${lanmu.name}" <c:if test="${huixian.lanmu_name eq lanmu.name}">selected</c:if>>
                                    ${lanmu.name}
                            </option>
                        </c:forEach>
                    </select>
                </div>
                <div class="col-md-6">
                    <label class="form-label required-label">供应商</label>
                    <select class="form-select" name="gongyingshang_name" required>
                        <option value="">-- 请选择 --</option>
                        <c:forEach items="${list2}" var="gongyingshang">
                            <option value="${gongyingshang.name}" <c:if test="${huixian.gongyingshang_name eq gongyingshang.name}">selected</c:if>>
                                    ${gongyingshang.name}
                            </option>
                        </c:forEach>
                    </select>
                </div>
            </div>

            <%-- 其他信息 --%>
            <div class="row mb-3">
                <div class="col-md-6">
                    <label class="form-label required-label">行程天数</label>
                    <input type="number" class="form-control" name="days"
                           value="${huixian.days}" min="1" required>
                </div>
                <div class="col-md-6">
                    <label class="form-label">图片更新</label>
                    <label class="form-label required-label">上传图片</label>
                    <input type="file" class="form-control" name="image" accept="image/*" required>
                    <c:if test="${not empty huixian.tou}">
                        <img class="user-avatar" src="<%=Res.fileUrl%>${huixian.tou}" width="50" height="50" alt="">
                    </c:if>
                </div>
            </div>

            <div class="mb-3">
                <label class="form-label">线路描述</label>
                <textarea class="form-control" name="miaoshu" rows="3">${huixian.miaoshu}</textarea>
            </div>
            <div class="mb-3">
                <label class="form-label">是否轮播</label>
                <select class="form-select" name="lunbo">
                    <option value="">-- 请选择 --</option>
                    <option value="1" <c:if test="${huixian.lunbo eq 1}">selected</c:if>>是</option>
                    <option value="0" <c:if test="${huixian.lunbo eq 0}">selected</c:if>>否</option>
                </select>
            </div>

            <div class="text-center">
                <button type="submit" class="btn btn-primary">提交修改</button>
                <a href="${pageContext.request.contextPath}/xianlu/list"
                   class="btn btn-outline-secondary">返回列表</a>
            </div>
        </form>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
